package cn.tedu.luckydrawuser.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.CorsRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;

@Configuration
public class CorsGlobalConfiguration implements WebFluxConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
//        WebFluxConfigurer.super.addCorsMappings(registry);
        registry.addMapping("/**")//对所有路径应用Cors配置
                .allowedOrigins("http://localhost:8080")//允许来自特定域的请求
                .allowedMethods("GET","POST","PUT","DELETE")//允许特定的请求方式
                .allowedHeaders("*")//允许的请求头
                .allowCredentials(true)//允许发送cookies
                .maxAge(3600);//设置预验请求的缓存时间（秒）
    }
}
